/**
 * 
 */
package com.leadership.entity.evaluation;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import com.leadership.entity.survey.SurveyResult;
import com.leadership.entity.user.User;
import javax.persistence.GenerationType;
/**
 * @author haiyan_xiao
 *
 */
@Entity
@Table(name = "evaluation")
public class Evaluation {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /** 学员邮箱 */
    private String email;

    /** 学员 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    private User user;

    /** 测评类型 */
    @Enumerated(EnumType.ORDINAL)
    private EvaluationType type;

    /** 测评时间 */
    private Date evaluationTime;

    /** 已完成/未完成 */
    @Column(name = "is_completed")
    private boolean completed;

    /** 报告 */
    private String report;
    
    private Long currentProjectId;

    @Column(name = "is_disabled")
    private boolean disabled;

    public Evaluation() {
        
    }
    
    /**
     * 
     * @param user
     * @param projectId
     * @param surveyResult
     * @param evaluationType
     */
    public Evaluation(User user, Long projectId, SurveyResult surveyResult, EvaluationType evaluationType) {
        this.user = user;
        this.email = user.getEmail();
        this.currentProjectId = projectId;
        this.type = evaluationType;
        this.completed = surveyResult.getStatus().equalsIgnoreCase("finish") ? true : false;
        this.report = surveyResult.getReport();
        this.disabled = false;
    }
    
    /**
     * 
     * @param surveyResult
     * @return
     */
    public Evaluation update(SurveyResult surveyResult) {
        this.completed = surveyResult.getStatus().equalsIgnoreCase("finish") ? true : false;
        this.report = surveyResult.getReport();
        
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @return the user
     */
    public User getUser() {
        return user;
    }

    /**
     * @return the type
     */
    public EvaluationType getType() {
        return type;
    }

    /**
     * @return the evaluationTime
     */
    public Date getEvaluationTime() {
        return evaluationTime;
    }

    /**
     * @return the completed
     */
    public boolean isCompleted() {
        return completed;
    }

    /**
     * @return the report
     */
    public String getReport() {
        return report;
    }

    /**
     * @return the currentProjectId
     */
    public Long getCurrentProjectId() {
        return currentProjectId;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @param user the user to set
     */
    public void setUser(User user) {
        this.user = user;
    }

    /**
     * @param type the type to set
     */
    public void setType(EvaluationType type) {
        this.type = type;
    }

    /**
     * @param evaluationTime the evaluationTime to set
     */
    public void setEvaluationTime(Date evaluationTime) {
        this.evaluationTime = evaluationTime;
    }

    /**
     * @param completed the completed to set
     */
    public void setCompleted(boolean completed) {
        this.completed = completed;
    }

    /**
     * @param report the report to set
     */
    public void setReport(String report) {
        this.report = report;
    }

    /**
     * @param currentProjectId the currentProjectId to set
     */
    public void setCurrentProjectId(Long currentProjectId) {
        this.currentProjectId = currentProjectId;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }
}
